package models

import "time"

type Follows struct {
	FollowID        uint64    `gorm:"column:follow_id;primary_key;auto_increment" json:"follow_id"`
	FollowerUserID  uint64    `gorm:"column:follower_user_id;not null" json:"follower_user_id" `
	FollowingUserID uint64    `gorm:"column:following_user_id;not null" json:"following_user_id"`
	FollowDate      time.Time `gorm:"column:follow_date;" json:"follow_date" `
}

// 关注
func (follow *Follows) Create() error {
	return DB.Self.Create(&follow).Error
}

// 取消关注
func (follow *Follows) Delete() error {
	return DB.Self.Delete(&follow).Error
}

// 查询所有
func GetFollow(userId uint64) ([]*Follows, error) {
	follows := make([]*Follows, 0)
	err := DB.Self.Where("follower_user_id = ?", userId).Find(&follows).Error
	return follows, err
}
